package kgc.crm.service.impl;

import kgc.crm.enums.LabelTypeEnum;
import kgc.crm.mapper.ActionRecordMapper;
import kgc.crm.model.ActionRecord;
import kgc.crm.service.IActionRecordService;
import kgc.crm.util.Constant;
import kgc.crm.util.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.util.Date;

@Service
@Slf4j
public class ActionRecordImpl implements IActionRecordService {
    @Autowired
    private ActionRecordMapper recordMapper;
    @Override
    public boolean addActionRecord(Long userId,Integer actionId,String val,String types) {
        ActionRecord  actionRecord = new ActionRecord();
        actionRecord.setCreateUserId(userId);//创建者id
        actionRecord.setActionId(actionId); //把线索id加进去 要操作对象id
        actionRecord.setTypes(types);//类型
        actionRecord.setContent(val);
        actionRecord.setCreateTime(new Date());
        try {
            int insert = recordMapper.insert(actionRecord);
            if (insert <= 0) {
                log.error("【添加线索模块】操作记录添加失败",actionRecord);
                return false;
            }
        } catch (Exception e) {
            log.error("【添加线索模块】操作线索添加失败",e);
            return false;
        }
        return true;
    }
}
